import { ERigidBody2DType } from "cc";
import { GlobalEnum } from "./GlobalEnum";

/**关卡中的碰撞体数据示例 */
export default class LevelDataTemplate {
    private constructor() { }
    public static getData(): any {
        return {
            "barrier1": {
                name: "barrier1",
                //刚体属性
                rigid: {
                    group: GlobalEnum.RigidGroup.default,
                    enabledContactListener: false,
                    bullet: false,
                    type: ERigidBody2DType.Static,
                    allowSleep: false,
                    gravityScale: 0,
                    linearDamping: 0,
                    angularDamping: 0,
                    linearVelocity: { x: 0, y: 0 },
                    angularVelocity: 0,
                    fixedRotation: true,
                    awakeOnLoad: true,
                },
                //碰撞体属性
                collider: [
                    {
                        type: "p",//碰撞体类型，c:circle,b:box,p:polygon
                        tag: 0,
                        group: GlobalEnum.RigidGroup.default,
                        density: 1,
                        sensor: false,
                        friction: 0,
                        restitution: 0,
                        offset: { x: 0, y: 0 },
                        //多边形数据：
                        points: [
                            { x: -0.5, y: -0.5 },
                            { x: -0.5, y: 0.5 },
                            { x: 0.5, y: 0.5 },
                            { x: 0.5, y: -0.5 },
                        ],
                        //矩形数据：
                        size: { w: 1, h: 1 },
                        //圆形数据：
                        radius: 0.5,
                    },
                ],

            },
            "plane1": {
                name: "plane1",
                //刚体属性
                rigid: {
                    group: GlobalEnum.RigidGroup.default,
                    enabledContactListener: false,
                    bullet: false,
                    type: ERigidBody2DType.Static,
                    allowSleep: false,
                    gravityScale: 0,
                    linearDamping: 0,
                    angularDamping: 0,
                    linearVelocity: { x: 0, y: 0 },
                    angularVelocity: 0,
                    fixedRotation: true,
                    awakeOnLoad: true,
                },
                collider: [
                    {
                        type: "p",//碰撞体类型，c:circle,b:box,p:polygon
                        tag: 0,
                        group: GlobalEnum.RigidGroup.default,
                        density: 1,
                        sensor: false,
                        friction: 0,
                        restitution: 0,
                        offset: { x: 0, y: 0 },
                        //多边形数据：
                        points: [
                            { "x": -0.075, "y": -4.561 },
                            { "x": -4.252, "y": -3.274 },
                            { "x": -5.372, "y": -1.015 },
                            { "x": -3.19, "y": 3.326 },
                            { "x": 0.152, "y": 4.488 },
                            { "x": 3.297, "y": 4.014 },
                            { "x": 4.813, "y": 0.426 },
                            { "x": 4.626, "y": -3.239 }
                        ],
                    }
                ]
            }
        }
    }
}